package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.STAFFMapper;
import com.ruoyi.system.domain.STAFF;
import com.ruoyi.system.service.ISTAFFService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 员工Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-08
 */
@Service
public class STAFFServiceImpl implements ISTAFFService 
{
    @Resource
    private STAFFMapper sTAFFMapper;

    /**
     * 查询员工
     * 
     * @param staffId 员工主键
     * @return 员工
     */
    @Override
    public STAFF selectSTAFFByStaffId(String staffId)
    {
        return sTAFFMapper.selectSTAFFByStaffId(staffId);
    }

    /**
     * 查询员工列表
     * 
     * @param sTAFF 员工
     * @return 员工
     */
    @Override
    public List<STAFF> selectSTAFFList(STAFF sTAFF)
    {
        return sTAFFMapper.selectSTAFFList(sTAFF);
    }

    /**
     * 新增员工
     * 
     * @param sTAFF 员工
     * @return 结果
     */
    @Override
    public int insertSTAFF(STAFF sTAFF)
    {
        String s1 = DateUtils.dateTime();
        String uuid = UUID.randomUUID().toString();

        String s="staff"+s1+uuid.substring(uuid.length()-5,uuid.length()-1);

        sTAFF.setStaffId(s);
        return sTAFFMapper.insertSTAFF(sTAFF);
    }

    /**
     * 修改员工
     * 
     * @param sTAFF 员工
     * @return 结果
     */
    @Override
    public int updateSTAFF(STAFF sTAFF)
    {
        return sTAFFMapper.updateSTAFF(sTAFF);
    }

    /**
     * 批量删除员工
     * 
     * @param staffIds 需要删除的员工主键
     * @return 结果
     */
    @Override
    public int deleteSTAFFByStaffIds(String staffIds)
    {
        return sTAFFMapper.deleteSTAFFByStaffIds(Convert.toStrArray(staffIds));
    }

    /**
     * 删除员工信息
     * 
     * @param staffId 员工主键
     * @return 结果
     */
    @Override
    public int deleteSTAFFByStaffId(String staffId)
    {
        return sTAFFMapper.deleteSTAFFByStaffId(staffId);
    }
}
